<?php namespace Core\Myapp\Helper\Admin\Form\Group\Element;

class Radio
{
    protected $_data = array();
    protected $_value = null;

    public function __construct($data)
    {
        $this->_data  = $data;
    }
    protected function setValue()
    {
        $view = \Registry::get('view');
        $form = $view->getForm();
        $this->_value = $form->getFieldValue($this->_data['name']);
    }
    public function render()
    {
        $this->setValue();
        ob_start();
        echo '<div class="form-element">';
        if($this->_data['label'])
            echo '<label for="'.$this->_data['name'].'" class="label">'.$this->_data['label'].'</label>';
        echo '<input type="radio" value="'.$this->_value.'" name="'.$this->_data['name'].'"/>';
        echo '</div>';
        $html = ob_get_clean();
        return $html;
    }
}